home *** CD-ROM | disk | FTP | other *** search
- var ybsidebar = {
-
- lastSidebarSearchValue : "", //the last search term used on the sidebar / not overlay popup.
- //_pinned : true, //this is being used from other files.
-
- _showingPopup : false,
- _setFlagTimer : 0,
-
- _prefService : null,
- _originalTooltipPrefVal : true,
- _tooltipPrefName : "browser.chrome.toolbar_tips",
-
- onLoad: function() {
- yDebug.print("Loading sidebar");
-
- ybsidebar._prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- var hideFFBMMenu = false;
- try {
- hideFFBMMenu = ybsidebar._prefService.getBoolPref("extensions.ybookmarks@yahoo.original.ui.hide");
- } catch ( e ) {}
-
- /*if (hideFFBMMenu) {
- var viewBookmarksSidebarKey =
- document.getElementById( "viewBookmarksSidebarKb" );
- viewBookmarksSidebarKey.setAttribute("command",
- "viewYBookmarksSidebar");
-
- // This element is defined only on windows firefox. Check the existance of the element before
- // using the element.
- var viewBookmarksSidebarWinKey =
- document.getElementById( "viewBookmarksSidebarWinKb" );
- if ( viewBookmarksSidebarWinKey ) {
- viewBookmarksSidebarWinKey.setAttribute("command",
- "viewYBookmarksSidebar");
- }
-
- var viewBookmarksSidebar =
- document.getElementById( "viewBookmarksSidebar" );
- viewBookmarksSidebar.setAttribute("hidden", "true");
-
- // remove bookmarks button from the toolbar
- var palette = document.getElementById( "navigator-toolbox" ).palette.firstChild;
- while ( palette ) {
- if ( palette.id == "bookmarks-button" ) {
- palette.parentNode.removeChild ( palette );
- }
-
- palette = palette.nextSibling;
- }
- }*/
- yDebug.print("Sidebar loaded", YB_LOG_MESSAGE);
- },
-
- onUnload : function() {
-
- },
-
- togglePopup : function(event) {
-
- var popup = document.getElementById("ybsidebar-popup");
- if ( this.isPopupHidden() )
- this.showPopup(event);
- else
- this.hidePopup();
- },
-
- showPopup: function(event) {
- /*
- var button = document.getElementById("del-button-delicious");
- if (!button || !window.toolbar.visible)
- return;
-
- var popup = document.getElementById("ybsidebar-popup");
- popup.firstChild.setPopupSize();
- popup.showPopup(button, -1, -1, "popup", "bottomleft", "topleft");
- popup.firstChild.search(this.lastSidebarSearchValue);
- popup.firstChild.setSearchBoxSelect();
- popup.firstChild.setPopupShowing(true);
- */
- },
-
- hidePopup : function() {
- /*
- var popup = document.getElementById("ybsidebar-popup");
- popup.firstChild.setPopupShowing(false);
- popup.hidePopup();
- */
- },
-
- isPopupHidden : function() {
-
- if (this._showingPopup) {
- return false;
- }
- else {
- return true;
- }
- },
-
- setPopupShowedState : function() {
-
- this._showingPopup = true;
-
- //hack to fix the tooltip problem
- this.storeOriginalTooltipPref();
- this.setTooltipPref(false);
- },
-
- setPopupHiddenState : function() {
-
- //XXX: When the popup is opened, clicking the button would re-open the popup again
- //In order to stop the popup opening again, a timeout is used to so that showingPopup = true
- //for the next 500 ms. When user releases the mouse button and within the 500ms, the popup would
- //not be opened.
- this._setFlagTimer = window.setTimeout(function(){
- ybsidebar._showingPopup = false; }, 500);
- var popup = document.getElementById("ybsidebar-popup");
- popup.firstChild.setPopupShowing(false);
-
- this.restoreOriginalTooltipPref();
- },
-
- closeSidebar : function() {
-
- var sidebarBox = document.getElementById("sidebar-box");
- var sidebarTitle = document.getElementById("sidebar-title");
- var sidebarSplitter = document.getElementById("sidebar-splitter");
- var elt = document.getElementById("viewYBookmarksSidebar");
- if (elt.getAttribute("checked") == "true") {
- elt.removeAttribute("checked");
- sidebarBox.setAttribute("sidebarcommand", "");
- sidebarTitle.setAttribute("value", "");
- sidebarBox.hidden = true;
- sidebarSplitter.hidden = true;
- content.focus();
- return;
- }
- },
-
- setTooltipPref : function(bool) {
-
- this._prefService.setBoolPref(this._tooltipPrefName, bool);
- },
-
- storeOriginalTooltipPref : function() {
-
- try {
-
- this._originalTooltipPrefVal = this._prefService.getBoolPref(this._tooltipPrefName);
- }
- catch (e) { this._originalTooltipPrefVal = true; }
- },
-
- restoreOriginalTooltipPref : function() {
- this.setTooltipPref(this._originalTooltipPrefVal);
- }
- };
-
- window.addEventListener("load", ybsidebar.onLoad, false);
- window.addEventListener("unload", ybsidebar.onUnload, false);
-